# Maintainer: Sylvain Rouquette <srouquette@gmail.com>

_realname=paper-terminal
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.0.0
pkgrel=1
pkgdesc="Print Markdown to a paper in your terminal (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64' 'mingw64')
url='https://github.com/foxfriends/paper-terminal'
msys2_references=(
  'purl: pkg:cargo/paper-terminal'
)
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
options=('!strip')
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('3d6726ae0861371a49cf69410294b73b38c7efa666dc7840ee6b29e6ff3088ee')
prepare() {
  cd "${_realname}-${pkgver}"

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd "${_realname}-${pkgver}"

  export WINAPI_NO_BUNDLED_LIBRARIES=1
  cargo build --release --frozen
}

check() {
  cd "${_realname}-${pkgver}"

  cargo test --release --frozen
}

package() {
  cd "${_realname}-${pkgver}"

  cargo install \
    --offline \
    --no-track \
    --frozen \
    --path . \
    --root "${pkgdir}${MINGW_PREFIX}"
}
